wcurl: fix missing argument crash for options#98
Merged
Conversation
sergiodj
requested changes
May 1, 2026
sergiodj
left a comment
Collaborator
There was a problem hiding this comment.
Thanks! There are some minor nits regarding the error message format. Let's get that fixed first :-).
20a8428 to
506a7cf
Compare
506a7cf to
1849ef2
Compare
|
Note that -z checks for empty and not whether an argument was given so the error is misleading if an empty argument was given. The wcurl argument parsing loop is similarly broken by checking for empty instead of checking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds input validation checks before
shiftis called for the--curl-optionsand-o/-O/--outputparameters.Currently, if a user passes
--curl-optionsor-oas the final argument without providing an actual value, the script blindly callsshiftand then attempts to read${1}. Because the script correctly usesset -eu, reading an unbound variable immediately crashes the program with an ugly shell interpreter error (unbound variableorparameter not set)....instead of a helpful user-facing error.
This is a small patch .... which catches the missing parameter and gracefully reports it using the
error()function.small test is also added here
testMissingArgumentErrortotests.shto explicitly verify behavior when an argument is omitted.